package com.gitee.xhs.savePointReader.broadcastState;

import com.gitee.xhs.broadcastState.BroadcastStateDao;
import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;

/**
 * @author BigHead
 * @date 2022/7/7 10:51
 * @description BroadcastStateReaderMapFunction
 */
public class BroadcastStateReaderMapFunction extends RichMapFunction<Tuple2<Long, BroadcastStateDao>, BroadcastStateExhibitor> {

    private final String jobId;
    private final String operatorUid;

    public BroadcastStateReaderMapFunction(String jobId, String operatorUid) {
        this.jobId = jobId;
        this.operatorUid = operatorUid;
    }

    @Override
    public BroadcastStateExhibitor map(Tuple2<Long, BroadcastStateDao> value) throws Exception {

        BroadcastStateExhibitor broadcastStateExhibitor = new BroadcastStateExhibitor();
        broadcastStateExhibitor.setJobId(jobId);
        broadcastStateExhibitor.setOperatorUid(operatorUid);
        broadcastStateExhibitor.setAccountId(value.f1.getAccountId());
        broadcastStateExhibitor.setDateTime(value.f1.getDataTime());
        broadcastStateExhibitor.setShowMessage(value.f1.getShowMessage());

        return broadcastStateExhibitor;
    }

}
